﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ExpenseSystem.Model;
using ExpenseSystem.Lor;
using ExpenseSystem.Common;
using ExpenseSystem.DataUpdater;
using ExpenseSystem.Fether;
using ExpenseSystem.Core.DataAddOn;

namespace ExpenseSystem.Core.RoleModules
{
    public class RoleBaseManager:RoleManager
    {

        RoleFetcher fetcher = new RoleFetcher();
        RoleModuleFetcher mFetcher = new RoleModuleFetcher();
        RoleSiteFetcher sFetcher = new RoleSiteFetcher();
        RoleUserFetcher uFetcher = new RoleUserFetcher();
        public override bool Delete(RoleModel role, out string message)
        {
            bool result = roleUpdater.Remove(role, tran, fetcher, out message);
            return result;
        }

        public override bool Delete(RoleModuleModel moduleRole, out string message)
        {
            bool result = roleModuleUpdater.Remove(moduleRole, tran, mFetcher, out message);
            return result;
        }

        public override bool Delete(RoleSiteModel siteRole,  out string message)
        {
            bool result = roleSiteUpdater.Remove(siteRole, tran, sFetcher, out message);
            return result;
        }

        public override bool Delete(RoleUserModel userRole,  out string message)
        {
            bool result = roleUserUpdater.Remove(userRole, tran, uFetcher, out message);
            return result;
        }

        public override bool DeleteById(long[] roleIds,  out string message)
        {
            bool result = true;
            result = roleUpdater.RemoveById(roleIds, tran, fetcher, out message);
            return result;
        }

        public override bool Save(RoleModel role, out string message, params IAddable<RoleModel>[] addables)
        {
            return roleUpdater.Save(role, tran, fetcher, out message);
        }

        public override bool Save(RoleModuleModel moduleRole,  out string message, params IAddable<RoleModuleModel>[] addables)
        {
            return roleModuleUpdater.Save(moduleRole, tran, mFetcher, out message);
        }

        public override bool Save(RoleSiteModel siteRole,  out string message, params IAddable<RoleSiteModel>[] addables)
        {
            return roleSiteUpdater.Save(siteRole, tran, sFetcher, out message);
        }

        public override bool Save(RoleUserModel userRole,  out string message, params IAddable<RoleUserModel>[] addables)
        {
            return roleUserUpdater.Save(userRole, tran, uFetcher, out message);
        }
    }
}
